import Adapter from "./adapter";

export default class WxAdapter extends Adapter {
    constructor() {
        super();
        this.name = 'wx';
    }

    save(data) {
        let OpenDataContext = wx.getOpenDataContext();
        OpenDataContext.postMessage({
            type: 3,
            data: data
        });
        return true;
    }

    getFriends(data) {
        let OpenDataContext = wx.getOpenDataContext();
        OpenDataContext.postMessage({
            type: 1,
            level: data
        });
        return true;
    }

    /**
     * 按10个等级归为1组的数据保存
     */
    saveLvlData(level, lvlData) {
        let OpenDataContext = wx.getOpenDataContext();
        OpenDataContext.postMessage({
            type: 4,
            data: lvlData,
            level: level
        });
        return true;
    }


    loadLvlData(level) {
        let OpenDataContext = wx.getOpenDataContext();
        OpenDataContext.postMessage({
            type: 5,
            level: level
        });
        return true;
    }

    freshMyScore(score){
        let OpenDataContext = wx.getOpenDataContext();
        OpenDataContext.postMessage({
            type: 2,
            score: score
        });
    }
};